<ui:composition template="/WEB-INF/templates/customer/base.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:define name="title">Carrello</ui:define>

	<ui:define name="content">
		<h:form>
			<p:fragment autoUpdate="true">
				<p:dataTable var="pack" value="#{cartBean.packages}">
					<p:column headerText="Nome">
						<h:outputText value="#{pack.model.name}" />
					</p:column>

					<p:column headerText="Prezzo">
						<h:outputText value="#{pack.price * pack.quantity}" />
					</p:column>

					<p:column headerText="Acquista">
						<p:commandButton value="Acquista" rendered="#{! pack.purchased and pack.model.valid}"
							action="#{cartBean.buy(pack)}" />
						<h:outputText value="Acquistato" rendered="#{pack.purchased}" />
						<h:outputText value="Non più valido" rendered="#{(! pack.model.valid) and (! pack.purchased)}" />
						<p:commandButton icon="ui-icon-close" action="#{cartBean.remove(pack)}" />
					</p:column>
				</p:dataTable>
			</p:fragment>
		</h:form>
	</ui:define>
</ui:composition>
